/*******************************************************************************
 * Copyright (c) 2012 Daniele Parisi.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     Daniele Parisi
 *     neb.inf@gmail.com
 *     http://www.danieleparisi.com/
 ******************************************************************************/
package org.jxreport.core.views.div;

import java.util.LinkedList;
import java.util.List;

import org.jxreport.core.HTMLUtils;
import org.jxreport.core.Table;
import org.jxreport.core.views.ViewObject;
import org.jxreport.html.HTMLView;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class DivView extends ViewObject {

	protected List<HTMLView> contents = new LinkedList<HTMLView>();

	public DivView(Element divElement, Table table){
		super(divElement, table);

		NodeList nl = divElement.getElementsByTagName("*");
		if(nl.getLength() > 0) 
		{
			for(int i = 0 ; i < nl.getLength();i++) {
				Element element = (Element)nl.item(i);
				if(element.getParentNode().getNodeName().equals(divElement.getNodeName()))
				{
					HTMLView reportView = HTMLUtils.getDOMElementToHTMLObjectClass(element, null);
					if(reportView != null) this.contents.add(reportView);
				}
				
			}
		}
	}

	public List<HTMLView> getContents() {
		return contents;
	}

	public void setContents(List<HTMLView> contents) {
		this.contents = contents;
	}
}
